package com.kwum.video;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.SequenceInputStream;

/**
 * @Description: 
 * @Company: yimo
 * @author: Kwum
 * @date 2018年2月9日 下午5:09:31
 */

public class UnionVideoDemo {
	
	private static final String file = "F:/CloudMusic/test001";
	private static final String ffile = "F:/CloudMusic/test001/999.mp4";

	public static void main(String args[])throws Exception{
		union(file, ffile);
	}
	
	public static void union(String path, String newString) throws Exception {
		File file = new File(path);
		File list[] = file.listFiles();
		File newFile = new File(newString);
		byte buffer[] = new byte[1024];
		int readcount;
		if (!newFile.getParentFile().exists())
			throw new Exception("你合并的文件夹的不存在...");
		FileOutputStream writer = new FileOutputStream(newString);
		for (File f : list) {
			System.out.println("++");
			FileInputStream reader = new FileInputStream(f);
			while ((readcount = reader.read(buffer)) != -1) {
				writer.write(buffer);
			}
			reader.close();
		}
		writer.close();
	}
	
}
